/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.easyidea.its.domain.model.system;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.easyidea.its.domain.model.BaseEntity;

/**
 * 
 * @author hukn
 */
@Entity
@Table(name = "Role")
public class Role extends BaseEntity {
	private static final long serialVersionUID = 1L;
	private String roleName;
	private Integer status;
	private String remark;
	private List<Permission> permissionList;
	private List<User> userList;
//	private List<Menu> serviceViews;
	public Role() {
	}


	@Column(name = "role_name", length = 100)
	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "RoleAndPermission", joinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "permission_id", referencedColumnName = "id"))
	public List<Permission> getPermissionList() {
		return permissionList;
	}

	public void setPermissionList(List<Permission> permissionList) {
		this.permissionList = permissionList;
	}

	@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}
//	@ManyToMany(fetch = FetchType.LAZY)
//	@JoinTable(name = "el_sa_role_ref_serviceview", 
//			joinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"), 
//			inverseJoinColumns = @JoinColumn(name = "serviceview_id", referencedColumnName = "id"))
//	public List<Menu> getServiceViews() {
//		return serviceViews;
//	}
//
//	public void setServiceViews(List<Menu> serviceViews) {
//		this.serviceViews = serviceViews;
//	}
}
